<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = new Array(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
        /* 数组去重 */
        Array.prototype.norepeat = function(){
            /* 
                1. 对数组进行排序
                2. 如果前一个和后一个一样,那么就干掉其中一个
            */
            // arr.sort(function(a,b){return a - b})

            // for(let i = 0 ; i < this.length ; i++){
            //     if(this[i] == this[i+1]){
            //         this.splice(i,1)
            //         i--;
            //     }
            // }

            // console.log(this);
            return [...new Set(this)];
        }
        let result = arr.norepeat();
        console.log(result);
    </script>
</body>

</html>